package ee.webmedia.xtee.client.service.callback;

import java.util.Random;

import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;

import ee.webmedia.xtee.client.service.configuration.XTeeServiceConfiguration;

/**
 * @author Kait Kasak (kait.kasak@nortal.com)
 */
public abstract class MessageCallbackNamespaceStrategy {

	private Random random = new Random(System.currentTimeMillis());

	/**
	 * Unique identifier for service invocation, consisting of numbers and
	 * letters of the Latin alphabet. The identifier is generated by service
	 * invoker, who must guarantee that the identifier is globally unique.
	 */
	protected String generateUniqueMessageId(XTeeServiceConfiguration serviceConfiguration) {
		return Long.toHexString(System.currentTimeMillis()) + serviceConfiguration.getInstitution() + random.nextInt();
	}

	public abstract void addNamespaces(SOAPEnvelope env) throws SOAPException;

	public abstract void addXTeeHeaderElements(SOAPEnvelope env, XTeeServiceConfiguration serviceConfiguration)
	        throws SOAPException;

}
